<?php

class ForumCTR extends Controller
{
    private $config;
    function init()
    {
        $ConfigModel = new Model('config');
        $config = $ConfigModel->fetch();
        $this->config = $config;
        $this->assign('config', $config);
    }

    function section()
    {
        if (!isset($_GET['id']) or empty($_GET['id'])) {
            $this->error('非法操作', $this->urlCreate('index', 'index'));
            exit;
        }
        $id = $_GET['id'] + 0;
        $SectionModel = new Model('section');
        $section = $SectionModel->fetch('*', array('id' => $id));
        $TopicModel = new Model('topic');
        $count = $TopicModel->count();
        $pages = ceil($count / 10);
        $nowpage = (isset($_GET['page']) && $_GET['page'] && $_GET['page'] + 0 > 0) ? $_GET['page'] +
            0 : 1;
        $start = ($nowpage - 1) * 10;
        $this->assign('start', $start);
        $this->assign('nowpage', $nowpage); //当前页面
        $this->assign('pages', $pages); //总页数
        $this->assign('last_url', $this->urlCreate('forum', 'section', array('id' => $id,
                'page' => $nowpage - 1)));
        $this->assign('next_url', $this->urlCreate('forum', 'section', array('id' => $id,
                'page' => $nowpage + 1)));
        $this->assign('login_user', Session::get('user'));
        $this->assign('section', $section);
        $this->assign('title', $section['name'] . ' - ' . $this->config['name']);
        $this->display();
    }
}

?>